package com.example.joke.custom.textcolor

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView.Adapter
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.example.joke.R


class VPAdapter : Adapter<VPAdapter.ViewPagerViewHolder>() {
    var list: MutableList<String> = mutableListOf()
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewPagerViewHolder {
        return ViewPagerViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_vp, parent, false))
    }

    override fun getItemCount(): Int {
        return list.size
    }

    override fun onBindViewHolder(holder: VPAdapter.ViewPagerViewHolder, position: Int) {
        holder.tv.text = list[position]
    }

    class ViewPagerViewHolder(itemView: View) :
        ViewHolder(itemView) {
        var tv: TextView

        init {
            tv = itemView.findViewById<TextView>(R.id.tv)
        }
    }


}